<template>
  <div :class="`bn-head ${headClass}`">
    <div class="bn-logo">
      <div class="img">
        <img src="@/assets/images/header/logo.png" width="40" height="40" />
      </div>
      <div class="img">
        <img src="@/assets/images/header/logo-name.png" width="255" height="26" />
      </div>
    </div>
    <div :class="`bn-nav ${currentNavClass}`">
      <div :class="`item  ${activeIndex==index?'activeItem':''}`" v-for="(item,index) in menuList" :key="item.id" @click="exchangeNav(index)">
        <img v-show="currentNavClass == 'current-' + (item.path && item.path.split('/')[1])" style="margin-right:8px;z-index:1;" :src="`static/images/menu/current-${item.path && item.path.split('/')[1]}.png`"/>
        <img v-show="currentNavClass != 'current-' + (item.path && item.path.split('/')[1])" style="margin-right:8px;z-index:1;" :src="`static/images/menu/${item.path && item.path.split('/')[1]}.png`"/>
        <span style="z-index:1">{{item.name}}</span>
      </div>
      <!-- <div class="item monitor" @click="exchangeNav('monitor')">
        <img  style="margin-right:8px;z-index:1;" src="@/assets/images/header/logo.png"/>
        运行监控111</div>
      <div class="item vehicleManage" @click="exchangeNav('vehicleManage')">车辆管理</div>
      <div class="item alarmRules" @click="exchangeNav('alarmRules')">规则管理</div>
      <div class="item statisticAnalyse" @click="exchangeNav('statisticAnalyse')">统计分析</div>
      <div class="item system" @click="exchangeNav('system')">系统管理</div> -->
    </div>
   
    <div class="bn-opt">
      <!-- <div class="user">
        {{real_name}}
      </div> -->
      <el-popover placement="bottom" width="200" trigger="click">
        <div class="changeUser">
          <div class="item" @click="handleLogOut">退出登录</div>
        </div>
        <!-- <el-button slot="reference">click 激活</el-button> -->
        <div class="user" slot="reference">{{ real_name }}</div>
        <!-- <div class="user" slot="reference">测试名</div> -->
      </el-popover>
    </div>
   
  </div>
</template>

<script>
import { logout } from '@/api/account'
import Cookie from 'js-cookie'
export default {
  data() {
    return {
      activeIndex:0,
      currentNavClass: 'current-monitor',
      real_name: '',
      isLogin: true,
      centerDialogVisible: false,
      headClass: 'headClassHome',
      policeDate: '',
      warningMsgData: {},
      testWarningIndex: 0,
      audioSource: 'http://192.168.101.71:8888/group1/M00/00/00/wKhlR2GE96iAfUbWAICQ-p9AJqs963.mp3',
      warningMsgList: [
        {warnTypeName: '超速报警', vehicleCode: '民航114591', vehicleTypeName: '牵引车', warnAreaName: '39R/17L区域', appUnit: '飞行区管理部', manageUnit: '场道保障科', warninTime: '2022-10-25 15:45:12'}
      ]
    }
  },
  mounted() {
   
  },
  props:['menuList'],

  computed: {
  },
  methods: {
    
    
    handleLogOut() {
      logout()
        .then((res) => {
          // localStorage.removeItem('checkedAreaKeyes')
          localStorage.clear()
          Cookie.remove('token')
          location.href = '/'
        })
        .catch((err) => {
          console.log(err, 'err')
          // localStorage.clear()
          // Cookie.remove('token')
          // location.href = '/'
        })
    },
    exchangeNav(index,params) {
      this.$emit('changeKey',index)
      this.activeIndex = index
    },
    changeClass(str) {
      if (str.indexOf('monitor') >= 0) {
        this.currentNavClass = 'current-monitor'
      } else if (str.indexOf('vehicleManage') >= 0) {
        this.currentNavClass = 'current-vehicleManage'
      } else if (str.indexOf('alarmRules') >= 0) {
        this.currentNavClass = 'current-alarmRules'
      } else if (str.indexOf('statisticAnalyse') >= 0) {
        this.currentNavClass = 'current-statisticAnalyse'
      } else if (str.indexOf('system') >= 0) {
        this.currentNavClass = 'current-system'
      } else if (str.indexOf('inspectionManage') >= 0) {
        this.currentNavClass = 'current-inspectionManage'
      }
    },

    
  },
  watch: {
    $route(to) {
      this.changeClass(to.path)
    },
  }
}
</script>
<style lang="less" scoped>
// @import '@/assets/css/variable.scss';
// $nav-height: 60px;

/* 选中样式 */
@mixin current-style {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 9px;
  width: 100px;
  height: 2px;
  background: #FFCB4D;
}



.changeUser {
  background-color: #fff;
  border: 1px solid #ccc;
  z-index: 600;
  border-radius: 8px;
  padding: 10px;

  .item {
    height: 40px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
  }

  .changePass {
    border-bottom: 1px solid #ccc;
  }
}

.bn-head {
  width: 100%;
  height: 60px;
  box-shadow: 3px 3px 6px 0px #000000, 1px 1px 4px 0px #000000, 0px -2px 2px 0px rgba(253, 253, 253, 0.12), 0px 1px 2px 0px rgba(253, 253, 253, 0.24);
  display: flex;
  justify-content: space-between;
  background-image: url('@/assets/images/header/bg.png');
  // background-image: url('../../../../static/images/homeBackground1.png');
  background-repeat: no-repeat;
  background-size: 100% 100%;

  .bn-logo {
    display: flex;
    flex-direction: row;
    line-height: 60px;

    .img {
      display: flex;
      align-items: center;

      &:nth-child(2) {
        margin-left: 10px;
      }
    }
  }

  .bn-nav {
    display: flex;

    .item {
      font-size: 20px;
      font-family: Microsoft YaHei;
      color: #ffffff;
      background: linear-gradient(0deg, rgba(146, 150, 155, 0.6) 0%, rgba(255, 255, 255, 0.6) 39.990234375%);
      -webkit-background-clip: text;
      // -webkit-text-fill-color: transparent;
      margin: 10px 0px 0px 0px;
      display: flex;
      align-items: center;
      position: relative;
      cursor: pointer;
      height: 40px;
      width: 140px;
    }
    /* 鼠标悬浮 */
    .item:hover::after {
      content: ' ';
      position: absolute;
      left: -3px;
      top: 3px;
      width: 120px;
      height: 35px;
      background: rgba(102, 106, 164, 0.4);
      border-radius: 5px;
    }
    /* 鼠标按下 */
   .item:active::after {
      content: ' ';
      position: absolute;
      left: -3px;
      top: 3px;
      width: 120px;
      height: 35px;
      background: rgba(0, 0, 0, 0.2);
      border-radius: 5px;
    }

  }
  .activeItem {
      font-weight: bold !important;
      color: #FFCB4D !important;

      &::after {
        @include current-style();
      }
    }
  .current-monitor {
    .item {
      font-weight: 400;
    }
    /* 标题选中样式 */
    .monitor {
      // font-weight: bold;
      // color: #FFCB4D;

      &::after {
        @include current-style();
      }
    }
  }

  .current-vehicleManage {
    .item {
      font-weight: 400;
    }

    .vehicleManage {
      font-weight: bold;
      color: #FFCB4D;
      &::after {
        @include current-style();
      }
    }
  }

  .current-alarmRules {
    .item {
      font-weight: 400;
    }

    .alarmRules {
      color: #FFCB4D;
      font-weight: bold;

      &::after {
        @include current-style();
      }
    }
  }

  .current-statisticAnalyse {
    .item {
      font-weight: 400;
    }

    .statisticAnalyse {
      font-weight: bold;
      color: #FFCB4D;
      &::after {
        @include current-style();
      }
    }
  }

  .current-inspectionManage {
    .item {
      font-weight: 400;
    }

    .inspectionManage {
      font-weight: bold;
      color: #FFCB4D;
      &::after {
        @include current-style();
      }
    }
  }

  .current-system {
    .item {
      font-weight: 400;
    }

    .system {
      color: #FFCB4D;
      font-weight: bold;
      &::after {
        @include current-style();
      }
    }
  }

  .bn-opt {
    display: flex;
    align-items: center;

    .user {
      display: flex;
      width: auto;
      height: 20px;
      background-image: url('@/assets/images/header/user.png');
      background-repeat: no-repeat;
      margin-left: 27px;
      margin-right: 30px;
      color: #fbfbfc;
      padding: 0 0 0 30px;
      cursor: pointer;
      font-size: 16px;
      // width: 20px;
      // overflow: hidden;
      // white-space: nowrap;
      // text-overflow: ellipsis;
    }
  }

  .dialog {
    position: absolute;
    top: 0;
    // height: 400px;
  }
}

.headClass {
 background-color: white;
}
.headClassHome {
 background-color: black;
}
</style>
